package com.example.parcelabledemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private TextView mTvID, mTvName, mTvAge;
    private Button mBtn;

    private int mID, mAge;
    private String mName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTvID = findViewById(R.id.textview_id);
        mTvName = findViewById(R.id.textview_name);
        mTvAge = findViewById(R.id.textview_age);

        this.mID   = Integer.valueOf(String.valueOf(mTvID.getText()));
        this.mName = String.valueOf(mTvName.getText());
        this.mAge  = Integer.valueOf(String.valueOf(mTvAge.getText()));
    }

    private void startActivity() {
        User user = new User();
        user.setId(mID);
        user.setName(mName);
        user.setAge(mAge);

        Intent intent = new Intent(this, TestActivity.class);
        Bundle bundle = new Bundle();
        bundle.putParcelable("12334567890", user);
        intent.putExtras(bundle);

        startActivity(intent);

    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.button:
                startActivity();
                break;
                default:
                    break;
        }
    }
}
